package org.csmzxy.class2334.timeclass;

import java.time.Duration;
import java.time.LocalDateTime;

public class Example15 {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        System.out.println("系统当前时间为" + now);
        LocalDateTime of = LocalDateTime.of(2023, 8, 1, 0, 0, 0);
        System.out.println("指定时间为" + of);
        Duration duration = Duration.between(of, now);
        System.out.println("当前时间与指定时间的时间间隔如下。");
        System.out.println("相差天数为" + duration.toDays());
        System.out.println("相差分钟数为" + duration.toMinutes());
        System.out.println("相差秒数为" + duration.toSeconds());
        System.out.println("相差纳秒数为" + duration.toNanos());
    }
}
